<template>
  <div class="teamCell" @click="cellClick">
    <div class="leftView">
      <img class="headImg" :key="data.pic" src="/web-hft-ee/static/img/university/avatar.png" v-real-img="data.pic">
      <div class="userView">
        <div class="nameView">
          <p class="nameLabel ellipsis1">{{data.nickname}}</p>
          <p v-if="data.roleType !== 0" class="creatorLabel">{{data.roleType === 1 ? '管理员' : '负责人'}}</p>
        </div>

        <p class="countLabel">学习值{{data.learnValue || 0}}</p>
      </div>
    </div>
<!--    <div class="rightView" v-if="showSetting" @click.stop="settingClick">-->
<!--      <img class="settingImg" src="/web-hft-ee/static/img/university/setting.png">-->
<!--    </div>-->
  </div>
</template>

<script>

  export default {
    name: "TeamCell",
    props: ["data"],
    computed: {

      //自己是否是管理员 0为成员 1为普通管理员 2为超级管理员
      roleType() {
        return this.$store.getters.enterpriseRoleInfo.roleType
      },
      //是否显示设置按钮
      showSetting() {
        if (this.roleType === 2) {
          //我是超级管理员
          if (this.data.roleType === 2) {
            //对象是超级管理员
            return false
          } else {
            return true
          }
        } else if (this.roleType === 1) {
          //我是普通管理员
          let permission = this.$store.getters.enterpriseRoleInfo.permission || "[1, 2]"
          permission = JSON.parse(permission)
          if (permission.length === 0) {
            //权限被关闭
            return false
          }
          if (this.data.roleType === 0) {
            return true
          } else {
            return false
          }
        } else {
          //我是普通成员
          return false
        }
      }
    },
    methods: {
      cellClick() {
        this.$_router.push('/university/userIndex/history/' + this.data.userid)
      },
      settingClick() {
        this.$emit('sendSettingClick')
      }
    }
  }
</script>

<style scoped>
  .teamCell {
    padding: 16px 0 16px 16px;
    background-color: white;
    justify-content: space-between;
    align-items: center;
    display: flex;
  }
  .leftView {
    justify-content: left;
    display: flex;
    align-items: center;
  }
  .headImg {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 20px;
  }
  .userView {
    margin-left: 16px;
    display: flex;
    flex-direction: column;
    align-items: start;
  }
  .nameView {
    display: flex;
    align-items: center;
    padding-right: 16px;
  }
  .nameLabel {
    color: #323334;
    font-size: 16px;
    font-weight: bold;
    flex: 1;
  }
  .creatorLabel {
    padding: 1px 2px;
    margin-left: 2px;
    background-color: #1CA562;
    font-size: 10px;
    color: #FFFFFF;
    border-radius: 2px;
  }
  .countLabel {
    margin-top: 4px;
    color: #98999E;
    font-size: 12px;
    font-weight: normal;
  }
  .rightView {
    padding: 12px;
  }
  .rightView:active {
    background-color: #DEDEDE;
  }
  .settingImg {
    width: 16px;
  }
</style>
